<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:form id="frmMiddleName">
            <p:growl id="messageGeneral" showDetail="true" sticky="false" />
            
            <p:dataTable id="tabListMiddleName" var="itemMiddleName"
                         value="#{mbVMiddleName.all}" paginator="true" rows="10"
                         paginatorPosition="bottom"
                         paginatorTemplate="{CurrentPageReport} {FirstPageLink} 
                                            {PreviousPageLink} {PageLinks} 
                                            {NextPageLink} {LastPageLink}"
                         emptyMessage="Нет отчеств"
                         filteredValue="#{mbVMiddleName.listMiddleNameFiltered}">
                <f:facet name="header">
                    Отчество                            
                </f:facet>
                <p:column width="100" headerText="Отчество" filterBy="name">
                    <h:outputText value="#{itemMiddleName.name}"/>
                </p:column>
                <p:column width="100">
                    <p:commandButton icon="ui-icon-disk" 
                                     action="#{mbVMiddleName.setMiddleNameParent()}"
                                     oncomplete="dialogMiddleName.hide()"
                                     style="float:right;width:32px;height:32px;">
                        <f:setPropertyActionListener value="#{itemMiddleName}"
                                                     target="#{mbVMiddleName.middleName}" />
                    </p:commandButton>
                    <p:commandButton icon="ui-icon-trash"
                                     oncomplete="deleteMiddleNameDlg.show()"
                                     style="float:right;width:32px;height:32px;">
                    <f:setPropertyActionListener value="#{itemMiddleName}"
                                                 target="#{mbVMiddleName.middleName}" />
                    </p:commandButton>
                    <p:commandButton update=":frmMiddleName:editMiddleNameDialog" 
                                     icon="ui-icon-pencil"
                                     oncomplete="editMiddleNameDlg.show()"
                                     style="float:right;width:32px;height:32px;">
                        <f:setPropertyActionListener value="#{itemMiddleName}"
                                                     target="#{mbVMiddleName.middleName}" />
                    </p:commandButton>                
                </p:column>
            </p:dataTable>
            <h:panelGroup layout="block" style="text-align: right">
                <p:commandButton value="Новое отчество" 
                                 oncomplete="newMiddleNameDlg.show()" />
            </h:panelGroup>
            
            <!-- Add new MiddleName -dialog -->
            <p:dialog widgetVar="newMiddleNameDlg" id="newMiddleNameDialog"
                      header="Новая отчество" hideEffect="fade" 
                      showEffect="fade" resizable="false" closable="true">
                <p:outputLabel value="Отчество" for="txtMiddleName"/>
                <p:inputText id="txtMiddleName" label="Отчество" size="50" 
                             value="#{mbVMiddleName.newName}">
                </p:inputText>
                <h:panelGroup layout="block" style="text-align: right">
                <p:commandButton value="Сохранить" action="#{mbVMiddleName.registration()}"
                                 oncomplete="newMiddleNameDlg.hide();" update="tabListMiddleName">
                </p:commandButton>
                <p:commandButton value="Отменить" oncomplete="newMiddleNameDlg.hide();"
                                 action="#{mbVMiddleName.cancel()}" />
                </h:panelGroup>
            </p:dialog>
            
            <!-- Delete MiddleName -dialog -->
            <p:dialog widgetVar="deleteMiddleNameDlg" id="deleteMiddleNameDialog"
                      header="Удаление отчества" hideEffect="fade"
                      showEffect="fade" resizable="false" 
                      closable="true">
                <h:outputText value="Удаляем отчество?" />
                <h:panelGroup layout="block" style="text-align: right">
                <p:commandButton value="Удалить" action="#{mbVMiddleName.remove()}"
                                 oncomplete="deleteMiddleNameDlg.hide();" update="tabListMiddleName">
                </p:commandButton>
                <p:commandButton value="Отменить"
                                 oncomplete="deleteMiddleNameDlg.hide();"
                                 action="#{mbVMiddleName.cancel()}" />
                </h:panelGroup>
            </p:dialog>
            
            <!-- Editing MiddleName -dialog -->
            <p:dialog widgetVar="editMiddleNameDlg" id="editMiddleNameDialog"
                      header="Редактирование отчества" hideEffect="fade"
                      showEffect="fade" resizable="false" closable="true">
                <p:outputLabel value="Отчество" for="txtMiddleNameUpdate"/>
                <p:inputText id="txtMiddleNameUpdate" label="Отчество" size="50" 
                             value="#{mbVMiddleName.middleName.name}"/>
                <h:panelGroup layout="block" style="text-align: right">
                <p:commandButton value="Сохранить" action="#{mbVMiddleName.update()}"
                                 oncomplete="editMiddleNameDlg.hide();" update="tabListMiddleName">
                </p:commandButton>
                <p:commandButton value="Отменить" oncomplete="editMiddleNameDlg.hide();"
                                 action="#{mbVMiddleName.cancel()}" />
                </h:panelGroup>
            </p:dialog>
            
            
            
            
                               
        </h:form>
</html>

